import requests
import json
import execjs
class Qcc():
    def __init__(self):
        self.headers = {
        "accept": "application/json, text/plain, */*",
        "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
        "cache-control": "no-cache",
        "content-type": "application/json",
        "origin": "https://www.qcc.com",
        "pragma": "no-cache",
        "priority": "u=1, i",
        "referer": "https://www.qcc.com/web/search?key=%E5%B0%8F%E7%B1%B3&p=3",
        "sec-ch-ua": "\"Microsoft Edge\";v=\"135\", \"Not-A.Brand\";v=\"8\", \"Chromium\";v=\"135\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Windows\"",
        "sec-fetch-dest": "empty",
        "sec-fetch-mode": "cors",
        "sec-fetch-site": "same-origin",
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0",
        "x-pid": "9e333529f350227f597a1877d3dddc1c",
        "x-requested-with": "XMLHttpRequest"
    }
        self.cookies = {
        "QCCSESSID": "974cc0c474b2868f67949f191f",
        "qcc_did": "2627a7e1-cea0-4394-91e7-f51e43581206",
        "UM_distinctid": "1964249237fe01-03776c2a536255-4c657b58-fa000-196424923801d82",
        "tfstk": "gXmrNl6Zo3KPlHiyt-qF70eH_kE8vuA6YDNQKvD3F7VuVksE8XMnFy4WwWuqtjU7ZBL8Kkr-c4sQNQEEKfZe1Ct6fYH8JkA61OBfWOZaLT2hOax02J_tvaPvfYHRnT5HCqx1LuI0lXVntz40nRP0EM2ot-j0MJehZJjk3xVYigjlrJ2cmRwaKkqntxv4pS2oM8hn1iyLrpw8yffNF_B3FYVVxMmyvzPalwsFY7euzyHugzzr08zzsyV4RbnoGvmS2rLO5kHj7XuninSrTY0it7iDsMPIWSamqXxOQSmrLmz-l_buQuPzS04cUgk4-qo4V0AdWxM4ZPrjlEd7RulrW5UkkIhE37Gn4rfyGWgsh04qsIsq9yuoa-qG4AfLnr0Ev45h8z2Y35923XJ5Ffk5eTLGJwU8k-P6ELbdJz2Y35923wQLPie41Lvl.",
        "acw_tc": "0a47318a17452875824841172e00710020e4f925174321b35276ace30a1571",
        "CNZZDATA1254842228": "26485078-1744868812-%7C1745288561"
    }
        self.url = "https://www.qcc.com/api/search/searchMulti"
        self.data = {
        "searchKey": "小米",
        "pageIndex": 3,
        "pageSize": 20
    }
        self.js = execjs.compile(open('01_企查查参数逆向.js', encoding='utf-8').read())

    def request_data(self):
        t='/api/search/searchMulti'
        hea = self.js.call('xxx', t,self.data)
        print(hea)
        self.headers[hea['key']] = hea['value']
        response = requests.post(self.url, headers=self.headers, cookies=self.cookies, json=self.data)
        print(self.data)
        print(response.text)
        print(response)

if __name__ == '__main__':
    qcc = Qcc()
    qcc.request_data()